package com.taplinker.client.im.rpc;

import com.taplinker.client.AppConfigFactory;
import com.taplinker.client.im.domain.BindData;
import com.taplinker.client.im.domain.ImDataCenter;
import com.taplinker.client.im.util.SimpleDBManager;
import com.taplinker.core.rpc.Result;


public class C103Cmd extends SimpleSocketCommand<C103RequestBody> {

	public C103Cmd(String conversionId)
	{
		C103RequestBody m_body = new C103RequestBody();
		m_body.setAppKey(AppConfigFactory.getInstance().getAppKey());
		m_body.setSdkAccount("user_"+conversionId);
		m_body.setConversationId(conversionId);
		body = m_body;
	}
	
	@Override
	public void yes(Result result) {
		try
		{
			SimpleDBManager.getInstance().getDataBase().delete("conversation", "conversationid = ?", new String[]{body.getConversationId()});
			ImDataCenter.getInstance().removeConversationByIdFromPri(body.getConversationId());
			ImDataCenter.getInstance().removeConversationByIdFromPub(body.getConversationId());
			BindData.getInstance().noticeView("LIST_REFRESH");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	@Override
	protected String getCommand() {

		return "103";
	}
}
